package com.yangyang.ralearn.client.rlclient;

import java.util.List;

import com.yangyang.ralearn.common.JEnvironment;
import com.yangyang.ralearn.common.entity.base.AbstractDomainPredicate;
import com.yangyang.ralearn.common.exception.ErrorActionException;
import com.yangyang.ralearn.common.exception.ReachGoalException;
import com.yangyang.ralearn.server.ServerManager;

public class RLSingleagentHandler implements IRLAgentHandler {

	private static final int GroupId = 1;
	private static final int SimulatorId = 1;

	@Override
	public JEnvironment init(String domainFile, String problemFile) {
		// TODO Auto-generated method stub
		ServerManager.instance().newGroup(GroupId, domainFile, SimulatorId,
				problemFile, null);
		return ServerManager.instance().getEnvironmentById(GroupId);
	}

	@Override
	public List<AbstractDomainPredicate> observe() {
		// TODO Auto-generated method stub
		return ServerManager.instance().getSimulatorById(GroupId,SimulatorId).observe();
	}

	@Override
	public boolean canDo(String line) {
		// TODO Auto-generated method stub
		return ServerManager.instance().getSimulatorById(GroupId,SimulatorId).canDo(line);
	}

	@Override
	public void doAction(String line) throws ReachGoalException,
			ErrorActionException {
		// TODO Auto-generated method stub
		ServerManager.instance().getSimulatorById(GroupId,SimulatorId).doAction(line);
	}

	@Override
	public void nextProblem(String problemFile) {
		// TODO Auto-generated method stub
		ServerManager.instance().nextProblem(GroupId,SimulatorId, problemFile);
	}

}
